// pages/weather/weather.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    setCity: '',
sendcityid:'',
    setcityid: ''
  },

  setcityInput: function (e) {
    this.setData({
      setCity: e.detail.value
    })
    //console.log(e.detail.value)
    var that = this;
    var setCity = that.data.setCity;
    var cityID = that.data.cityID;
    var setcityid = that.data.setcityid;
    console.log(setcityid)
    console.log(setCity)
    var url = "https://geoapi.heweather.net/v2/city/lookup?location=" + setCity + "&key=9ae57296512f49beb1c2dff138ac5eb7";
    //console.log(url)
    wx.request({     
      url: url,
      success(res) {
        console.log(res.data.location[0].id)
        that.setData({
          setcityid: res.data.location[0].id
        })
      }
    });
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  getweather: function () {
    var setcityid= this.data.setcityid
    var sendcityid= setcityid
  console.log(setcityid)
  console.log(sendcityid)
    wx.navigateTo({
      url: '/pages/showweather/showweather?sendcityid=' +setcityid,
    })
  
  },
 
 








  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    //   wx.request({
    //     url: sendCity,

    //     success:e=>
    //     {

    //             this.setData({lifestyle : e.data.daily})

    // } 
    // }) 
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    console.log(cid)
  }
})